package cn.brilliantfuture.commentry.entity;

// Generated 2012-8-20 13:35:08 by Hibernate Tools 3.3.0.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * RechargeCard generated by hbm2java
 */
@Entity
@Table(name = "recharge_card", catalog = "cabinet", uniqueConstraints = {
		@UniqueConstraint(columnNames = "card_passwd"),
		@UniqueConstraint(columnNames = "card_sn") })
public class RechargeCard implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer rechargeCardId;
	private String cardSn;
	private String cardPasswd;
	private String plaintextPasswd;
	private double faceValue = 0.0D;
	private int cardState = 1;
	private Date expireTime;
	private boolean selected;
	private Set<RechargeCardStateRecord> rechargeCardStateRecords = new HashSet<RechargeCardStateRecord>(0);

	public RechargeCard() {
	}

	public RechargeCard(String cardSn, String cardPasswd, double faceValue, boolean selected, 
			int cardState, Date expireTime) {
		this.selected = selected;
		this.cardSn = cardSn;
		this.cardPasswd = cardPasswd;
		this.faceValue = faceValue;
		this.cardState = cardState;
		this.expireTime = expireTime;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "recharge_card_id", unique = true, nullable = false)
	public Integer getRechargeCardId() {
		return this.rechargeCardId;
	}

	public void setRechargeCardId(Integer rechargeCardId) {
		this.rechargeCardId = rechargeCardId;
	}

	@Column(name = "card_sn", unique = true, nullable = false, length = 50)
	@NotNull
	@Length(max = 50)
	public String getCardSn() {
		return this.cardSn;
	}

	public void setCardSn(String cardSn) {
		this.cardSn = cardSn;
	}

	@Column(name = "card_passwd", unique = true, nullable = false, length = 50)
	@NotNull
	@Length(max = 50)
	public String getCardPasswd() {
		return this.cardPasswd;
	}

	public void setCardPasswd(String cardPasswd) {
		this.cardPasswd = cardPasswd;
	}

	@Column(name = "face_value", nullable = false, precision = 22, scale = 2)
	public double getFaceValue() {
		return this.faceValue;
	}

	public void setFaceValue(double faceValue) {
		this.faceValue = faceValue;
	}

	@Column(name = "card_state", nullable = false)
	public int getCardState() {
		return this.cardState;
	}

	public void setCardState(int cardState) {
		this.cardState = cardState;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "expire_time", nullable = false, length = 19)
	@NotNull
	public Date getExpireTime() {
		return this.expireTime;
	}

	public void setExpireTime(Date expireTime) {
		this.expireTime = expireTime;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "rechargeCard")
	public Set<RechargeCardStateRecord> getRechargeCardStateRecords() {
		return rechargeCardStateRecords;
	}

	public void setRechargeCardStateRecords(
			Set<RechargeCardStateRecord> rechargeCardStateRecords) {
		this.rechargeCardStateRecords = rechargeCardStateRecords;
	}

	@Transient
	public String getPlaintextPasswd() {
		return plaintextPasswd;
	}

	public void setPlaintextPasswd(String plaintextPasswd) {
		this.plaintextPasswd = plaintextPasswd;
	}

	@Transient
	public boolean isSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
	}
}
